﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLM.ConfigurationCenter.Core {
    public class AppHelper {
        /// <summary>
        /// 
        /// </summary>
        private static IServiceProvider? serviceProvider;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="provider"></param>
        public static void Initialization(IServiceProvider provider ) {
            serviceProvider = provider;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T GetService<T>() where T : class {
            //创建服务容器
            var res = serviceProvider.GetRequiredService<T>();
            return res;
        }
    }
}
